package com.workflow.sdk.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.workflow.sdk.infra.repository.mapper.WorkflowInfoMapper;
import com.workflow.sdk.infra.repository.model.WorkflowInfoPo;
import com.workflow.sdk.infra.repository.WorkflowInfoRepository;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 流程信息表 服务实现类
 * </p>
 *
 * @author cyj
 * @since 2022-06-01
 */
@Service
public class WorkflowInfoRepositoryImpl extends ServiceImpl<WorkflowInfoMapper, WorkflowInfoPo> implements WorkflowInfoRepository {

    public WorkflowInfoPo getByWorkflowName(String workflowName) {
        LambdaQueryWrapper<WorkflowInfoPo> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(WorkflowInfoPo::getWorkflowName, workflowName);
        return getOne(lambdaQueryWrapper, false);
    }

    public WorkflowInfoPo getByWorkflowCode(String workflowCode) {
        LambdaQueryWrapper<WorkflowInfoPo> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(WorkflowInfoPo::getWorkflowCode, workflowCode);
        return getOne(lambdaQueryWrapper, false);
    }

}
